package controllers;

import java.util.List;

import services.BackInfoService;
import services.CountHistoryService;
import utils.BizConstants;
import vos.BackCountVo;
import vos.BackInfoVo;
import vos.CountHistorySearchVo;
import vos.ReturnListVo;

public class CountHistoryController extends BaseController{
	/**
	 * 历史统计页面
	 *
	 * @Title: counthistory 
	 * @return: void
	 */
	public static void counthistory(){
		render();
	}
	/**
	 * 获取历史统计
	 *
	 * @Title: getHistory 
	 * @param page
	 * @param rows
	 * @param sort
	 * @param order
	 * @param dealerid 经销商id
	 * @param dealername 经销商name
	 * @return: void
	 */
	public static void getHistory(int page,int rows, String sort,String order,String dealerid,String dealername,String cmonth){
		if(page==0){
			page=1;
		}
		if(rows==0){
			rows=BizConstants.pagesize;
		}
		CountHistorySearchVo vo=new CountHistorySearchVo(page,rows,sort,order,dealerid,dealername,cmonth);
		long total=CountHistoryService.countCountHistory(vo);
		ReturnListVo listVo=new ReturnListVo();
		listVo.setTotal(total);
		List<BackCountVo> lists=CountHistoryService.listCountHistory(vo);
		listVo.setRows(lists);
		renderJSON(listVo);
	}
	/**
	 * 获取子表数据
	 *
	 * @Title: getSub 
	 * @param page
	 * @param rows
	 * @param sort
	 * @param order
	 * @param dealerid 经销商id
	 * @param cmonth 月份
	 * @return: void
	 */
	public static void getSub(int page,int rows, String sort,String order,String dealerid,String cmonth){
		if(page==0){
			page=1;
		}
		if(rows==0){
			rows=BizConstants.pagesize;
		}
		CountHistorySearchVo vo=new CountHistorySearchVo(page,rows,sort,order,dealerid,cmonth);
		long total=CountHistoryService.countSubHistory(vo);
		ReturnListVo listVo=new ReturnListVo();
		listVo.setTotal(total);
		List<BackCountVo> lists=CountHistoryService.listSubHistory(vo);
		listVo.setRows(lists);
		renderJSON(listVo);
	}
}
